<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<meta http-equiv="pragma" content="no-cache">
		<link rel="stylesheet" type="text/css" href="js/tools/easyui/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="js/tools/easyui/themes/icon.css">
		<script type="text/javascript" src="js/tools/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="js/tools/easyui/easyloader.js"></script>
		<script type="text/javascript" src="js/tools/easyui/jquery.easyui.min.js"></script>
<script charset="utf-8" src="js/tools/editor/kindeditor-min.js"></script>
<script type="text/javascript" src="js/tools/jqueryurl.js"></script>
<script charset="utf-8" src="admin/js/public.js"></script>
<style>
table {font-size: 12px;}
table tr {background-color: #F1F6F6;}
table tr td {border: 1px solid #D9D9D9;color: black;padding: 2px;}
</style>
<script type="text/javascript">
var user='<s:property value="#session.user"/>';
KE.show({
				id : 'content',
				resizeMode : 1,
				imageUploadJson : 'image!uploadImageForEditor.action',
				directory:"uploadfile/news",
				width:800,
				height:400
			});
$(function(){
	$("input[type='checkbox']").click(function(){
	  if( $(this).attr("checked"))
	  {
	    $("#cont").hide();
	  }else
	  {
	    $("#cont").show();
	  }
	});
	var isNav='<s:property value="websiteColumn.isNav"/>';
	if(isNav==1)
	{
	  $("input[type='checkbox']").attr("checked",true);
	  $("#cont").hide();
	}
	var columnId=$.query.get("columnId");
	$("#columnId").val(columnId);
	categoryList("categoryId",columnId,-1,function(){
	   var isMofidy='<s:property value="news"/>';
	   if(isMofidy!='')
	   {
	       var categoryId='<s:property value="news.categoryId"/>';
	       var subCategoryId='<s:property value="news.subCategoryId"/>';
	      $("#categoryId").val(categoryId);
	     
		      categoryList("subCategoryId",columnId,categoryId,function(){
		         $("#subCategoryId").val(subCategoryId);
		      });
	      var recommend='<s:property value="news.recommend"/>'
	      if(recommend=="1")
	      {
	         $("#recommend").attr("checked",true);
	      }else
	      {
	         $("#recommend").attr("checked",false);
	      }
	   }
	});
});
function check()
{
   $("#name,#categoryId,#url").css("border","");
   var title=$.trim($("#title").val());
   var categoryId=$("#categoryId").val();
   var subCategoryId=$("#subCategoryId").val();
   var content=$.trim($("#content").val());
   if(title.length<1||title.length>21)
   {
     $("#title").css({"border": "2px solid red"});
      alert("标题的长度为1~100");
      return false;
   }
   if(categoryId==-2)
   {
      alert("必需选择根类别!");
      $("#categoryId").css({"border": "2px solid red"});
      return false;
   }
   if(content.length<1||content.length>5000)
   {
      alert("内容的长度在1~5000");
      return false;
   }
  return true;
};

</script>
	</head>
	<body>
	<s:actionmessage/>
	<s:if test="%{news == null}">
	    <form action="news!addNews.action" method="post" onsubmit="return check();">
	</s:if>
	<s:else>
	     <form action="news!modifyNews.action" method="post" onsubmit="return check();">
	     <input type="hidden" name="news.id" value="<s:property value="news.id"/>">
	</s:else>
	 <input type="hidden" name="columnId" id="columnId" value="">
		<table  style="width: 98%;" align="center">
			<tr><td width="10%">新闻标题:</td><td><input type="text" name="news.title" id="title" value="<s:property value="news.title"/>"/></td></tr>
			<tr><td>新闻类别:</td><td><select id="categoryId" name="news.categoryId" onchange="categoryList('subCategoryId',$.query.get('columnId'),$(this).val());"></select>&nbsp;&nbsp;子类别：<select name="news.subCategoryId" id="subCategoryId"><option value='-2'>选择类别</option></select></td></tr>
			<tr><td>推荐:</td><td><input type="checkbox" name="news.recommend" id="recommend" value="1"/></td></tr>
			<tr><td>新闻内容:</td><td><div><textarea name="news.content" id="content" rows="" cols=""><s:property value="news.content"/></textarea></div></td></tr>
			<tr><td><input type="submit" onclick="" value="保存"/></td><td></td></tr>
		</table>
	</form>
	</body>
</html>
